#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll d[100009],v[100009],a[100009],p[100009],ans=0;
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ll t,n,m,L,V;
    cin>>t;
    for(int k=1;k<=t;k++)
    {
        ans=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++)cin>>d[i]>>v[i]>>a[i];
        for(int i=1;i<=m;i++)cin>>p[i];
        ll r=p[m];
        for(int i=1;i<=n;i++)
        {
            if(a[i]!=0)
            {
                double temp=(double)2.00*a[i]*(r-d[i])+v[i]*v[i];
                temp=sqrt(temp);
                if(temp>V&&d[i]<=p[m])ans++;
            }
            else
            {
                if(v[i]>V&&d[i]<=p[m])ans++;
            }
        }
        cout<<ans<<" ";
        if(ans!=0)cout<<m-1<<"\n";
        else cout<<m<<"\n";
    }
    return 0;
}
